package com.lilihub.miaosha.redis;

/**
 * @BelongsProject: miaosha
 * @BelongsPackage: com.lilihub.miaosha.redis
 * @Author: LiYing
 * @CreateTime: 2021-04-24 15:03
 * @Description:
 */
public abstract class BasePrefix implements KeyPrefix{


    private int expireSeconds;

    private String prefix;


    public BasePrefix(String prefix) {    //默认0代表永不过期
        this.expireSeconds = 0;
        this.prefix = prefix;
    }

    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }


    @Override
    public int expireSeconds() {
        return expireSeconds;
    }



    @Override
    public String getPrefix() {

        String className = getClass().getSimpleName();

        return className + ":" + prefix;
    }
}
